package com.ktwlsoft.archivemanage.config.exception;

import com.ktwlsoft.archivemanage.payload.Result;
import com.ktwlsoft.archivemanage.payload.ResultType;
import lombok.Data;

/**
 * 自定义返回异常
 *
 * @author Name on 2023/7/21 10:01
 * @version 1.0
 */
@Data
public class ResultException extends RuntimeException{

    private Result<?> result;

    public ResultException(String message,ResultType resultType,Object data){
        super(message);
        result = Result.body(data,resultType).withMessage(message);
    }

    public ResultException(String message,ResultType resultType){
        super(message);
        result = Result.body(null,resultType).withMessage(message);
    }

    public ResultException(String message){
        super(message);
        result = Result.body(null,ResultType.BUSINESS_ERROR).withMessage(message);
    }
}